package com.fxf.srb.core.controller.admin;

import com.fxf.common.result.R;
import com.fxf.srb.core.pojo.entity.BorrowInfo;
import com.fxf.srb.core.pojo.vo.BorrowInfoApprovalVO;
import com.fxf.srb.core.service.IBorrowInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author 饭小范
 * @version 1.0
 * @description: TODO
 * @date 2021/6/2 22:43
 */
@Api(tags = "借款管理")
@RestController
@RequestMapping("/admin/core/borrowInfo")
@Slf4j
public class AdminBorrowerInfoController {

    @Resource
    public IBorrowInfoService iBorrowInfoService;

    @ApiOperation(value = "借款信息列表")
    @GetMapping("/list")
    public R list(){
        List<BorrowInfo> borrowInfoList = iBorrowInfoService.selectList();
        return R.ok().data("borrowerInfoList",borrowInfoList);
    }

    @ApiOperation(value = "获取借款信息")
    @GetMapping("/show/{id}")
    public R show(
            @ApiParam(value = "借款id", required = true)
            @PathVariable Long id){
        Map<String, Object> borrowInfoDetail = iBorrowInfoService.getBorrowInfoDetail(id);
        return R.ok().data("borrowInfoDetail",borrowInfoDetail);
    }

    @ApiOperation("审批借款信息")
    @PostMapping("/approval")
    public R approval(@RequestBody BorrowInfoApprovalVO borrowInfoApprovalVO){


        iBorrowInfoService.approval(borrowInfoApprovalVO);
        return R.ok().message("审批完成");
    }
}
